/*
 * Remove Duplicates from Sorted Array
 */
#include "../../func.h"

int removeDuplicates1(vector<int> &nums)
{
    if (nums.empty())
        return 0;

    int idx = 0;
    for (int i = 1; i < nums.size(); ++i) {
        if (nums[idx] != nums[i]) {
            nums[++idx] = nums[i];
        }
    }
    return idx+1;
}

int removeDuplicates(vector<int> &nums)
{
    return std::distance(nums.begin(), std::unique(nums.begin(), nums.end()));
}